/**
 * @param {number} n
 * @return {number}
 */
 var cuttingRope = function(n) {
    let res=0;
    for(let i=2;i<=n;i++){
        res=Math.max(res,max(n,i));
    }
    return res;
    function max(num,count){
        let a=Math.floor(num/count),b=num%count;
        return Math.pow(a,count-b)*(b==0?1:Math.pow(a+1,b));
    }
};

console.log(cuttingRope(120))